home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _43E6F0B0FF2E4C8E8694244D0DF2B57B < prev    next >
Text File  |  2005-02-17  |  1KB  |  57 lines

  1. //bird flap shader
  2. //1 directional light and ambient light applied
  3. //Luke Lenhart
  4. //(C)2004-2005 Digipen Institute of Technology
  5.  
  6. //combined world,view,projection transform
  7. float4x4 matWorldViewProj;
  8.  
  9. //1 directional light
  10. float4 l1Direction;
  11. float4 l1Color;
  12. float4 lAmbient;
  13.  
  14. //current time (in seconds) since whenever
  15. float time;
  16.  
  17. //shader input
  18. struct VS_INPUT
  19. {
  20.     float4 Pos : POSITION;
  21.     float4 Normal : NORMAL;
  22.     float2 Tex0 : TEXCOORD0;
  23. };
  24.  
  25. //shader output
  26. struct VS_OUTPUT
  27. {
  28.     float4 Pos : POSITION;
  29.     float4 Color : COLOR;
  30.     float2 Tex0 : TEXCOORD0;
  31. };
  32.  
  33. //shader code
  34. VS_OUTPUT VShader(VS_INPUT In)
  35. {
  36.     VS_OUTPUT Out;
  37.     
  38.     //calc colors from directional light
  39.     float4 l1Contrib=dot(-In.Normal,l1Direction)*l1Color;
  40.     l1Contrib=saturate(l1Contrib);
  41.     Out.Color=l1Contrib + lAmbient;
  42.     Out.Color.a=1;
  43.     
  44.     //oscillate position based on distance from the middle axis, to make the wing flap
  45.     float4 pos=In.Pos;
  46.     pos.z+=sin(time)*abs(In.Pos.y);
  47.     
  48.     //do world/view/project transform
  49.     Out.Pos=mul(matWorldViewProj,pos);
  50.     
  51.     //copy texture coord through
  52.     Out.Tex0=In.Tex0;
  53.     
  54.     //spit out the results
  55.     return Out;
  56. }
  57.